<!DOCTYPE HTML>
<html>
  <head>
    <title>Blogs</title>
        <link type = "image/x-icon" rel="SHORTCUT ICON" href="img/favicon.ico" />	
        <script type="text/javascript" src="jquery/jquery-1.7.1.min.js"></script>     
		<link rel="stylesheet" href="css/style.css" />
        <link rel="stylesheet" href="css/grid-12.css" /> 
  </head>
  <body>
    <div id="container" class="container_12">
    
    <?php
    include("inc/db.class.php");
		require("php/header.php");
		include("inc/functions.php");
		?>
      <div id="line" class="grid_12"></div>
			<div id="" class="grid_12">
				<h3>Blogs</h3>
<?php 
require('connection.php');

$query = "select * from blogs order by modified_at desc";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)){
	$date = new DateTime();
	$date->setTimestamp($row['modified_at']);
	$updated_date = $date->format('Y-M-d H:i');
	$query_user = "select first_name, last_name from users where id=".$row['created_by'];
	$result_user = mysql_query($query_user);
	$user = mysql_fetch_assoc($result_user);
	
	echo '<div class="blog_list">
            <div>
				<div><a href="#"><b>'.$row['title'].'</b></a></div>
				<div class="title" style="padding-top: 4px;">'.substr($row['description'],0,500).'</div>
				<div class="title"><b>Auther:</b> '.$user['first_name'].' '.$user['last_name'].'    <b>Updated Time:</b> '.$updated_date.'</div>
				<div class="title"><b>Tags:</b> '.$row['tags'].'</div>
			</div>
         </div>';
         echo '<div class="clear"></div>';
}
?>
			</div>
						
			<?php require("php/footer.php"); ?>
    </div>
  </body>
</html>
